//
// Created by antler on 2018/12/6.
//

#ifndef LUA_RECT_H
#define LUA_RECT_H

#include "luaext/size/Size.h"

#define CLASSNAME_RECT "Rect"
#define USERTYPE_RECT "Rect"

class Rect {
public:
    static Rect ZERO;

public:
    static Rect *create();

    static Rect *createWith(int x, int y, int width, int height);

    static Rect *createWith(const Point &origin, const Size &size);

    static Rect *createWith(const Rect &rect);

    Rect();

    Rect(int x, int y, int width, int height);

    bool isEmpty() const;

    // 获取矩形的左上角坐标
    Point tl();

    // 获取矩形的右下角坐标
    Point br();

    // 判断矩形是否包含坐标
    bool contains(const Point &point);

    // 矩形合并操作
    Rect unionRect(const Rect &other);

    // 矩形相切操作
    Rect intersectRect(const Rect &other);

public:
    int x, y;
    int width, height;
};


#endif //LUA_RECT_H
